/* ----------------------------------------------------------------------------
* File: common.h
*
* Desc: Common definitions for project
*
* Created: 21/02/2011, by Alexey Korshunov
* ---------------------------------------------------------------------------- */
#ifndef _COMMON_H_
#define _COMMON_H_

#include <stdio.h>
#include <stdarg.h>
#include <stdlib.h>
#include <string.h>
#include <iostream>
#include <unistd.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <pthread.h>
#include <errno.h>

#include <vector>
#include <map>
#include <algorithm>

#include <sys/types.h>
#include <sys/stat.h>
#include <syslog.h>
#include <signal.h>
#include <time.h>


/************************************************************************/
/*	Default options														*/
/************************************************************************/
#define BOX_DEFAULT_MIN_THREADS			1
#define BOX_DEFAULT_MAX_THREADS			256
#define BOX_MAX_RECV_SIZE				512
#define BOX_DEFAULT_READ_CHUNK			1024 * 64	// 64Kb
#define BOX_DEFAULT_CONTROL_PORT		5555
#define BOX_DEFAULT_DATA_PORT			5556
#define BOX_DEFAULT_MAX_CONN			256


/************************************************************************/
/*	Timeouts															*/
/************************************************************************/
#define BOX_POOL_TIMEOUT			2		// sec
#define BOX_START_THREAD_TIMEOUT	1		// 1sec
#define BOX_STOP_THREAD_TIMEOUT		1		// sec
#define BOX_SEND_TIMEOUT			10		// ms
#define BOX_RECV_TIMEOUT			10		// ms
#define BOX_AUTH_TIMEOUT			5000	// 5sec
#define BOX_SELECT_TIMEOUT			1000	// 1sec

#define BOX_WAIT_FILE_CHANGE		1		// sec


/************************************************************************/
/*	Returned codes														*/
/************************************************************************/
#define BOX_SERVER_OK				0
#define BOX_SERVER_ERROR			-1
#define BOX_SERVER_OUT_OF_MEMORY	-2


#define WAIT_FOREVER		-1
#define CONFIG_STRING_LEN	256
#define CONFIG_DTRECTORY	"../../config/"


void my_syslog_err(const char* msg, ...);
void my_syslog_inf(const char* msg, ...);

#endif // _COMMON_H_